﻿using System;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using SAKS.Models;
using SAKS.IServices;
using NHibernate;

namespace SAKS.Services
{
    public class SearchServices : ISearchServices
    {
        public ISession Session { get; set; }
        public IEnumerable<DocumentInfo> ProDocSearch(Guid projectId, int start, int pageSize, out int? totalRecords, string key)
        {
            var query = new Query.PagedFullTextSearch<DocumentInfo, DocFile>(Session)
            {
                Id = projectId,
                First = start,
                PageSize = pageSize,
                Key = key,
                Colume = "ProjectId"
            };
            var result = query.Execute();
            totalRecords = result.TotalItems;
            return result.PageOfResults; 
        }

        public IEnumerable<ConferenceReportInfo> ReportSearch(Guid projectId, int start, int pageSize, out int? totalRecords, string key)
        {
            var query = new Query.PagedFullTextSearch<ConferenceReportInfo, ConferenceReportFile>(Session)
            {
                Id = projectId,
                First = start,
                PageSize = pageSize,
                Key = key,
                Colume = "ProjectId"
            };
            var result = query.Execute();
            totalRecords = result.TotalItems;
            return result.PageOfResults; 
        }

        public IEnumerable<DocumentInfo> AchiDocSearch(Guid AchiId, int start, int pageSize, out int? totalRecords, string key)
        {
            var query = new Query.PagedFullTextSearch<DocumentInfo, DocFile>(Session)
            {
                Id = AchiId,
                First = start,
                PageSize = pageSize,
                Key = key,
                Colume = "AchievementId"
            };
            var result = query.Execute();
            totalRecords = result.TotalItems;
            return result.PageOfResults; 
        }

    }


}
